﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel.Design.Serialization;
 
namespace PhotoOrganizer
{
    [Serializable]
    public class File
    {
        //private byte[] fileHash;
        private DateTime? createdDateTime;
        private string originalSource;
        private string newSource;
        private string extention;
        public List<string> comapredTo;

        //[IgnoreDataMember]
        //public Microsoft.Test.VisualVerification.Snapshot bmp;

        public bool IsImage
        {
            get
            {
                return ".gif,.jpg,.png,.jpeg,.bmp,".IndexOf(Extention + ",") >= 0;
            }
        }

        public string Extention
        {
            get
            {
                if (extention == null)
                    extention = originalSource.Substring(originalSource.LastIndexOf(".")).ToLower();
                return extention;
            }
        }

        public DateTime? CreatedDateTime
        {
            get
            {
                return this.createdDateTime;
            }
            set
            {
                this.createdDateTime = value;
            }
        }

        public string OriginalSource
        {
            get
            {
                return this.originalSource;
            }
            set
            {
                this.originalSource = value;
            }
        }

        public string NewSource
        {
            get
            {
                return this.newSource;
            }
            set
            {
                this.newSource = value;
            }
        }

        public bool Compare(File pOtherFile)
        {
            bool tResult = false;

            //if (this.bmp == null) this.bmp = Microsoft.Test.VisualVerification.Snapshot.FromFile(originalSource);

            //if (pOtherFile.bmp == null) this.bmp = Microsoft.Test.VisualVerification.Snapshot.FromFile(pOtherFile.OriginalSource);

            //tResult = this.bmp.CompareTo(pOtherFile.bmp);
            return tResult;
        }
    }
}
//private: Bitmap^ bmp;
//private: Rectangle rect;
//private: array<Byte>^rgbValues;
//private: int bytes;
//private: Byte shade;
//private: IntPtr ptr;
//private: System::Drawing::Imaging::BitmapData^ bmpData;
//private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
//{
//    // Write pixel to array. Stride * pixel y, gives us the position of next scanline. 
//    for ( int counter = 0; counter < rgbValues->Length; counter += 4 )
//    {
//            rgbValues[ counter ] = 0; // Blue channel.
//            rgbValues[ counter + 1 ] = 0; // Green channel.
//            rgbValues[ counter + 2 ] = 255; // Red channel.
//            rgbValues[ counter + 3 ] = shade; // Alpha channel ( 255 = solid color, 0 = background colour ).
//    }

//    // Lock the bitmap's bits.
//    bmpData = bmp->LockBits( rect, System::Drawing::Imaging::ImageLockMode::ReadWrite, bmp->PixelFormat );
//    // Get the address of the first line.
//    // Pointer to the start of bitmap memory. It is FLAT and can be treated as a one-dimensional array.
//    ptr = bmpData->Scan0;
//    // Copy the ARGB values to the bitmap. Remember it will be BGRA.
//    // DWORDS or QWORDS written to the bitmap are alot more efficient. This is from windows MSDN so i will stick with this.
//    System::Runtime::InteropServices::Marshal::Copy( rgbValues, 0, ptr, bytes );
//    // Unlock the bits.
//    bmp->UnlockBits( bmpData );
//    // Set the PictureBox to display the image.
//    // Not sure this is legal but it allows me to use alpha channel to create volumetric fog / smoke, haze, light for free!
//    pictureBox1->Image = bmp;
//    // Increase alpha channel by 16 everytime button is pressed.
//    shade += 16;
//}

//private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
//shade = 0;
//// Create a new bitmap.
//// Bitmap("filename", true) will load a bitmap file into the memory bitmap.
//bmp = gcnew Bitmap( pictureBox1->Width,pictureBox1->Height,System::Drawing::Imaging::PixelFormat::Format32bppArgb );

//// Lock the bitmap's bits.
//rect = Rectangle(0,0,bmp->Width,bmp->Height);
//bmpData = bmp->LockBits( rect, System::Drawing::Imaging::ImageLockMode::ReadWrite, bmp->PixelFormat );
//// Declare an array to hold the bytes of the bitmap.
//// This code is specific to a bitmap with 32 bits per pixels.
//// Always use stride * height, not width * height.
//bytes = bmpData->Stride * bmp->Height;
//rgbValues = gcnew array<Byte>(bytes);
//// Unlock the bits.
//bmp->UnlockBits( bmpData );
//// Display the pixel format in Label1.
//label1->Text = String::Format( "Pixel format: {0}", bmp->PixelFormat );
////See if stride equals 640 * 4 = 2560, can also equal -2560.
//numericUpDown1->Value = bmpData->Stride;
////Compare to Width * 4
//numericUpDown2->Value = bmp->Width * 4;
////If bmp->Width * 4 is equal to bmpData->Stride then we can write to one-dimensional array.
//} 